﻿<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
<script type="text/javascript" src="../lib/html5.js"></script>
<script type="text/javascript" src="../lib/respond.min.js"></script>
<script type="text/javascript" src="../lib/PIE_IE678.js"></script>
<![endif]-->
    <link href="../css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="../css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="../lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
    <!--[if IE 6]>
<script type="text/javascript" src="../lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
    <title>作业管理</title>
    <style type="text/css">
        .auto-style1 {
            width: 40px;
        }
    </style>
</head>
<body>
    <div class="pd-5">
        <div class="text-c" id="findfdiv">
            <span class="select-box" style="width: 150px">
                <select class="select" size="1" name="findtype" id="findtype"  onchange="findreolad()">
                    <option value="生产任务">生产任务</option>
                    <option value="育苗任务">育苗任务</option>
                    <option value="">全部</option>
                </select></span>
            <span class="select-box" style="width: 200px;">
                <select class="select" size="1" name="findareaid" id="findareaid"></select>
            </span>
            <input type="text" class="input-text" style="width: 250px" placeholder="任务编号" id="findtaskno" name="findtaskno">
            <button onclick="findreolad()" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 查询</button>
        </div>
        <div class="cl pd-5 bg-1 bk-gray mt-5">
            <span class="l">
                <a href="javascript:;" onclick="addTaskListInfo('22','清园')" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe603;清园</i></a>
                <a href="javascript:;" onclick="addTaskListInfo('33','打地')" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe64d;打地</i></a>
                <a href="javascript:;" onclick="addTaskListInfo('44','底肥')" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe6d1;底肥</i></a>
                <a href="javascript:;" onclick="addTaskListInfo('55','整地')" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe6c9;整地</i></a>
                <a href="javascript:;" onclick="addTaskListInfo('66','播种')" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe6d3;播种</i></a>
                <a href="javascript:;" onclick="addTaskListInfo('77','水肥')" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe6b2;水肥</i></a>
                <a href="javascript:;" onclick="addTaskListInfo('88','植保')" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe6ac;植保</i></a>
                <a href="javascript:;" onclick="addTaskListInfo('99','育苗')" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe6bb;育苗</i></a>
                <a href="javascript:;" onclick="addTaskListInfo('1010','选苗')" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe606;选苗</i></a>
                <a href="javascript:;" onclick="addTaskListInfo('1111','采收')" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe672;采收</i></a>
                <a href="javascript:;" onclick="addTaskListInfo('1212','报废')" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe688;报废</i></a>
                <a href="javascript:;" onclick="addTaskListInfo('1313','移值')" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe672;移值</i></a>
            </span>
            <span class="r">操作提示：<strong>^_^</strong> </span>

        </div>
        <div class="mt-5 ml-20">
            <table class="table table-border table-bordered table-striped table-hover" id="tablelist" width="100%">
                <thead>
                    <tr class="text-c">
                        <th width="30"><a id="hcmtable_sall" onclick="hcmtable_sall();" href="javascript:;" title="全选反选"><i class="Hui-iconfont">&#xe608;全</i></a></th>
                        <th>区域</th>
                        <th>地块</th>
                        <th>面积</th>
                        <th>品种</th>
                        <th>最近作业</th>
                        <th>任务编号</th>
                        <th>任务时间</th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
    </div>
    <script src="../hcjsui/Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../lib/layer/1.9.3/layer.js"></script>
    <script type="text/javascript" src="../lib/laypage/1.2/laypage.js"></script>
    <script type="text/javascript" src="../lib/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="../lib/datatables/1.10.0/jtable.js"></script>
    <script src="../hcjsui/js/_Define.js" type="text/javascript"></script>
    <script type="text/javascript" src="../js/hcui.js"></script>
    <script type="text/javascript" src="../js/hcui_list.js"></script>
    <script type="text/javascript">
        function test()
        { alert(1);}
        $(function () {
            spsetBaseNoBt("viewtask_dctask", "id", "viewtask_dctask as T", "*", "#tablelist", "sctasklistnew", "作业", "sctasklistnew");
            //加载区域
            hcdoselbyPost("id,fv1 as name", "yw_baseinfo", "type='5' and  maintype='5' and databranchid=" + HCUser.HCUorg, "", "", "id", function (data) {
                SetSelectWithArrayIdName("#findareaid", data);
            });
            hcmtable = $("#tablelist").DataTable({
                "serverSide": true,//服务端处理分页 无法使用当前查找
                "bFilter": false,  //是否使用内置的过滤功能
                "bInfo": true, "fnDrawCallback": function () { dTappendSkipPage(); },
                "bLengthChange": false, //改变每页显示数据数量
                "ajax": {
                    "type": "POST",
                    "url": spselUrl("and databranchid=" + HCUser.HCUorg) + "&sporderby=areaname,areadcno,dataaddtime desc ",
                    "data": function (d) {
                        $("#findfdiv").find("input[type='text']").each(function () {
                            d[this.id] = $(this).val();
                        });
                        $("#findfdiv").find("select").each(function () {
                            d[this.id] = $(this).val();
                        });

                    }
                },
                "order": [[1, "asc"]],//默认第几个排序
                aLengthMenu: [10, 20, 50],
                "columns": [
                    { "data": "rowhcindex" }, { "data": "areaname" }, { "data": "areadcno" }, { "data": "areadcmj" }, { "data": "tasksctypename" }, { "data": "newwork" }, { "data": "taskno" }, { "data": "dataaddtime" }
                ],

                "columnDefs": [
                    //不排序
                   {
                       "orderable": false,
                       "targets": [0, 1, 2, 3, 4, 5, 6]
                   }

                ]
            });
        });
        function addTaskListInfo(workinfotype) {


            //var ID = "";
            //var rowdata = hcmtable.rows('.selected').data();
            //var slen = rowdata.length;
            //if (slen < 1) {
            //    layer.alert('请选择要修改的内容');
            //    return;
            //}
            ////if (slen > 1) { layer.alert('选择了多个，将处理第一个!'); }
            //for (var i = 0; i < slen; i++) {
            //    ID = rowdata[i][pTableIdName];
            //    break;
            //}
            //toolUpdateById(ID);

            var rowdata = hcmtable.rows('.selected').data();
            console.log(rowdata);

            var slen = rowdata.length;
            if (slen < 1) {
                layer.alert('请选择要进行作业的记录');
                return;
            }
            if (slen == 1) {//单一操作
                toolAdd("添加作业信息", "sctasklist-work-ae.html?action=add&urltaskid=" + rowdata[0]["id"] + "&urlinfoid=" + rowdata[0]["areadcid"] +
                    "&urlinfoname=" + rowdata[0]["areadcno"] + "&urlinfomj=" + rowdata[0]["areadcmj"] + "&urlworkinfotype=" + workinfotype);
            }
            else {//批量操作
                var taskidlist = "";
                var areadcidlist = "";
                var areadcnolist = "";
                var areadcmjlist = "";

                for (var i = 0; i < slen; i++) {
                    taskidlist += rowdata[i]["id"] + ",";
                    areadcidlist += rowdata[i]["areadcid"] + ",";
                    areadcnolist += rowdata[i]["areadcno"] + ",";
                    areadcmjlist += rowdata[i]["areadcmj"] + ",";
                }
                taskidlist = taskidlist.substring(0, taskidlist.length - 1);
                areadcidlist = areadcidlist.substring(0, areadcidlist.length - 1);
                areadcnolist = areadcnolist.substring(0, areadcnolist.length - 1);
                areadcmjlist = areadcmjlist.substring(0, areadcmjlist.length - 1);
                toolAdd("批量添加作业信息", "sctasklist-work-ae.html?action=addlist&urltaskid=" + taskidlist + "&urlinfoid=" + areadcidlist +
                     "&urlinfoname=" + areadcnolist + "&urlinfomj=" + areadcmjlist + "&urlworkinfotype=" + workinfotype);
            }

        }
    </script>
</body>
</html>
